package kr.hkit.androidcomplete01.ch07;

import kr.hkit.androidcomplete01.ch07.Primitive1.MyView;
import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RectF;
import android.os.Bundle;
import android.view.View;

public class Primitive2 extends Activity {
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		setContentView(new MyView(this));
		
	}
	
	class MyView extends View {
		
		private Paint paint;
		private Rect r;
		private RectF rect;
		
		public MyView(Context context) { //우린 하나만 해여
			super(context);
			paint = new Paint(Paint.ANTI_ALIAS_FLAG); //안티엘리어싱 기능있음
			//r = new Rect(200, 0, 300, 100);
			rect = new RectF(10L, 10L, 100L, 100L);
		}
		
		@Override
		protected void onDraw(Canvas canvas) {
			super.onDraw(canvas);
	
			paint.setColor(Color.LTGRAY);
			canvas.drawPaint(paint); //캔버스 바탕색칠하기
			
			//빨간색 둥근 사각형
			paint.setColor(Color.RED);
			canvas.drawRoundRect(rect, 10, 10, paint);
			
			//297페이지임 
			
			//타원
			rect.set(110, 10, 150, 100);
			canvas.drawOval(rect, paint);
			
			//분홍색 반달
			paint.setColor(Color.MAGENTA);
			rect.set(10, 110, 100, 200);
			canvas.drawArc(rect, 10, 150, false, paint);
			
			//분홍색 파이
			rect.set(110, 110, 200, 200);
			canvas.drawArc(rect, 10, 150, true, paint);
			
			//파란색 대각선
			paint.setColor(Color.BLUE);
			float[] pts = {10,210,50,250,50,250,110,220};
			canvas.drawLines(pts, paint);
			
			//검은색 점 3개
			paint.setColor(Color.BLACK);
			float[] pts2 = {20,210,50,240,100,220};
			canvas.drawPoints(pts2, paint);
			
		}
	}
}
